const workers=[];

for(let i=0;i<4;i++){
    workers.push(new Worker("./worker.js"))
}

let responseCount=0;
for(const worker of workers){
    worker.onmessage=()=>{
        if(++responseCount==workers.length){
            console.log(view[0]);
        } 
    }
}

const sharedArrayBuffer=new SharedArrayBuffer(4);
const view=new Uint32Array(sharedArrayBuffer);

view[0]=1;

for(const worker of workers){
    worker.postMessage(sharedArrayBuffer);
}